package com.hilinos.base.app.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hilinos.base.api.vo.OrgInfoVo;
import com.hilinos.base.app.OrgApp;
import com.hilinos.base.service.OrgInfoService;
import com.hilinos.base.user.entity.pojo.OrgInfoPoJo;
import com.hilinos.common.entity.BaseQo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OrgAppImpl implements OrgApp {


    @Autowired
    private OrgInfoService orgInfoService;

    public void create(OrgInfoPoJo orgInfo) {
        orgInfoService.save(orgInfo);
    }

    @Override
    public IPage<OrgInfoPoJo> pageList(BaseQo<OrgInfoPoJo, OrgInfoPoJo, OrgInfoPoJo> qo) {
        return orgInfoService.page(qo.page(), qo.queryWrapper());
    }

    /**
     * 查询机构信息
     *
     * @param orgId
     * @return
     */
    public OrgInfoPoJo detail(String orgId, String appid) {
        return orgInfoService.detail(orgId, appid);
    }

    /**
     * 查询父机构信息
     *
     * @param orgId
     * @return
     */
    public OrgInfoPoJo parent(String orgId, String appid) {
        return orgInfoService.parent(orgId, appid);
    }

    /**
     * 查询下一级子机构
     *
     * @param orgId
     * @return
     */
    public List<OrgInfoPoJo> child(String orgId, String appid) {
        return orgInfoService.child(orgId, appid);
    }

    /**
     * 查询所有子机构
     *
     * @param orgId
     * @return
     */
    public List<OrgInfoVo> childs(String orgId, String appid) {
        return orgInfoService.childs(orgId, appid);
    }

    @Override
    public void edit(OrgInfoPoJo orgInfo) {
        orgInfoService.edit(orgInfo);
    }

}
